
sequenceDiagram
    participant M as Main
    participant G as Game
    participant B as Board
    participant D as Difficulty
    participant U as UI
    participant C as Constants
    M->>G: start()
    G->>D: get_difficulty()
    D-->>G: return level
    G->>B: init_board()
    B-->>G: return initialized board
    G->>U: render_board(board)
    U->>C: fetch COLORS, TILE_SIZE, MARGIN
    C-->>U: return constants
    U->>G: display_score(0)
    G->>U: display_restart_button()
    loop Game Loop
        G->>G: update()
        G->>B: move_tiles(direction)
        B-->>G: return move_successful
        G->>B: add_new_tile()
        G->>U: render_board(board)
        G->>U: display_score(score)
        G->>G: check_game_over()
    end
    G->>U: display_game_over()
    U->>G: handle_input(restart)
    G->>G: reset_game()
